<?php
/**
 * Controller class
 * Superclass of all application controllers
 * @package shakephp
 * @subpackage core
 */
abstract class Controller {
	/**
	 * Variables that will be used by the view
	 * @var array
	 * @access private
	 */ 
	private $view_vars = array();
	
	/**
	 * Sends variables to the view
	 * @param string $a Name of the variable in the view scope
	 * @param mixed $b Value assigned to the variable
	 * @access public 
	 */
	public function set($a, $b) {
		if(isset($a) && isset($b))
			$this->view_vars[$a] = $b;
	}
	
	/**
	 * Renders the view
	 * @param string $file The view to be rendered, without extension
	 * @param string|array $layout [optional] Layouts that will be used 
	 * 
	 * The parameter $layout can be either a string containing the filename
	 * of a layout without extension (for simple layouts) or an array of 
	 * layouts (for nested layouts). In the case of nested layouts, the view
	 * will render from the most external (first element of the aray) 
	 * to the most internal (last element of the array).
	 */
	public function view($file, $layout = null) {
		$view = new View($file, $layout, $this->view_vars);
		$view->render();
	}
}
?>